import Taro, { Component } from '@tarojs/taro'
import { View, Text ,Radio, RadioGroup, Label, Button, Image} from '@tarojs/components'
import './authphone.css'
import app from '../../main.js';
import { AtButton } from 'taro-ui'
import { fail } from 'assert';
import { STATUS_CODES } from 'http';

export default class Index extends Component {

  config = {
    navigationBarTitleText: '获取手机号码'
  }

  constructor(){
    super(...arguments);
    this.state={
      test:{
        name:"joe",
        age:20
      }
    } 
  }

  getPhoneNumber (e) {
    var me = this;
    console.log('获取手机号码', e)
    if (app.isEmpty(app.sessionKey)) {
      app.decidePage();
      return;
    }
    var data = {
      sessionKey: app.sessionKey,
      encryptedData: e.detail.encryptedData,
      iv: e.detail.iv
    };
    app.post('web/patient/setPhone', data, function(res) {
      app.decidePage();
    })
  }

  componentWillMount () {
    
  }

  componentDidMount () {}

  componentWillUnmount () { }

  componentDidShow () { }

  componentDidHide () { }
   
  render () {
    return (
      <View>
        <View className='top'>
          <View className='v_logo'>
            <Image className='logo' src={app.imageUri + 'img/logo_patient.png'} />
          </View>
          <View className='title'>爱眼医生</View>
        </View>
        <View className='content'>
          <View className='c_head'>登录后将获得以下权限</View>
          <View className='c_title'>
            <Image src={app.imageUri + 'img/check-box.png'} style='width:50rpx;height:50rpx;' />
            <View style='margin-left:20rpx;'>获得您的手机号码</View>
          </View>
        </View>
        <View className='bottom'><Button className='b_btn' lang="zh_CN" openType="getPhoneNumber" onGetPhoneNumber={this.getPhoneNumber}>确认</Button></View>
      </View>
    )
  }
}

